<?php

namespace common\models\c2\statics;

use Yii;

/**
 * RegionType
 *
 * @author ben
 */
class FromInputType extends AbstractStaticClass
{

    const INPUT = 'XInput';  // load in when demand
    const SELECT = 'XSelect';  // province
    const CHECKBOX = 'XCheckBox';  // city
    const TEXTAREA = 'XTextarea';  // district
    const XFILEINPUT = 'XFileInput';  // district

    protected static $_data;

    /**
     *
     * @param type $id
     * @param type $attr
     * @return string|array
     */
    public static function getData($id = '', $attr = '')
    {
        if (is_null(static::$_data)) {
            static::$_data = [
                static::INPUT => ['id' => static::INPUT, 'component' => 'XInput'],
                static::SELECT => ['id' => static::SELECT, 'component' => 'XSelect'],
                static::CHECKBOX => ['id' => static::CHECKBOX, 'component' => 'XCheckBox'],
                static::TEXTAREA => ['id' => static::TEXTAREA, 'component' => 'XTextarea'],
            ];
        }
        if ($id !== '' && !empty($attr)) {
            return static::$_data[$id][$attr];
        }
        if ($id !== '' && empty($attr)) {
            return static::$_data[$id];
        }
        return static::$_data;
    }

    public static function getComponent($id)
    {
        return static::getData($id, 'component');
    }

}
